package com.shinhye.elephantsafe;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

public class GuardThrefActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		SharedPreferences sp = getSharedPreferences("Setting", MODE_PRIVATE);
		boolean skip_guide = sp.getBoolean("skipguide", false);
		
		if(skip_guide) {
			setContentView(R.layout.activity_guardthref);
			ImageView iv_lock = (ImageView) findViewById(R.id.iv_lock_state);
			String sim = sp.getString("SIM", null);
			String safephone = sp.getString("safephone", "");
			
			//假如跳过设置，导致SIM卡没绑定或没有安全号码，则重设开启防盗为false.
			if(TextUtils.isEmpty(sim) || TextUtils.isEmpty(safephone)) {
				Editor editor = sp.edit();
				editor.putBoolean("RunGuard", false);
				editor.commit();
			}
			boolean runguard = sp.getBoolean("RunGuard", false);
			if(runguard) {
				iv_lock.setImageResource(R.drawable.lock);
			} else {
				iv_lock.setImageResource(R.drawable.unlock);
			}
			
		} else {
			Intent intent = new Intent(this, GuardSetup1Activity.class);
			startActivity(intent);
			finish();
			overridePendingTransition(R.anim.translate_in_from_up, 0);
		}
	}
	
	public void gotoguide(View v) {
		Intent intent = new Intent(this, GuardSetup1Activity.class);
		startActivity(intent);
		finish();
		overridePendingTransition(R.anim.translate_in_from_up, 0);
	}
}
